package com.dubbo.test.lock;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

import java.nio.charset.Charset;

/**
 * 布隆过滤器
 * zj: 可能存在数据映射 bitmap ,bloomFilter.put 提前缓存
 *    请求—> 布隆过滤器 —> 是否包含 mightContain
 */
public class BloomFilterDemo {

    public static void main1(String[] args) {
        BloomFilter bloomFilter=BloomFilter.create
                (Funnels.stringFunnel(Charset.defaultCharset()),
                        1000000,0.001); //1%
        bloomFilter.put("mic1");
        System.out.println(bloomFilter.mightContain("mic"));
    }
}
